//
//  HomeViewController.m
//  SuningBeaulty
//
//  Created by HappyMilk 02 on 2017/4/14.
//  Copyright © 2017年 HappyMilk 02. All rights reserved.
//

#import "HomeViewController.h"
#import "PublicTool.h"
#import "UIViewController+XLBubbleTransition.h"

@interface HomeViewController ()

//跳过按钮
@property (nonatomic ,strong) UIButton *skilp;

@property (weak, nonatomic) IBOutlet UIButton *btn_1;
@property (weak, nonatomic) IBOutlet UIButton *btn_2;
@property (weak, nonatomic) IBOutlet UIButton *btn_3;
@property (weak, nonatomic) IBOutlet UIButton *btn_4;





@end

@implementation HomeViewController

- (IBAction)pushNextVC:(UIButton *)sender {
    
//    UIModalTransitionStyleCoverVertical
//    UIModalTransitionStyleFlipHorizontal
//    UIModalTransitionStyleCrossDissolve
//    UIModalTransitionStylePartialCurl
    self.xl_pushTranstion = nil;
    self.xl_popTranstion = nil;
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"FirstViewController"];
    //vc.modalTransitionStyle =  UIModalTransitionStylePartialCurl;
    //[self presentViewController:vc animated:YES completion:nil];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //粒子动画
    [self emitterAnimetion];
    
    //登陆按钮
    [self loginButtonCreate];
    
    //分类按钮
    [self categroyButtonModify];
    
    
}
- (void)categroyButtonModify{
    
    self.btn_1.layer.masksToBounds = YES;
    self.btn_1.layer.cornerRadius = 6;
    self.btn_1.layer.borderColor = HEXCOLOR(0xAFA7EB).CGColor;
    self.btn_1.layer.borderWidth = 1.5;
    
    self.btn_2.layer.masksToBounds = YES;
    self.btn_2.layer.cornerRadius = 6;
    self.btn_2.layer.borderColor = HEXCOLOR(0xAFA7EB).CGColor;
    self.btn_2.layer.borderWidth = 1.5;
    
    self.btn_3.layer.masksToBounds = YES;
    self.btn_3.layer.cornerRadius = 6;
    self.btn_3.layer.borderColor = HEXCOLOR(0xAFA7EB).CGColor;
    self.btn_3.layer.borderWidth = 1.5;
    
    self.btn_4.layer.masksToBounds = YES;
    self.btn_4.layer.cornerRadius = 6;
    self.btn_4.layer.borderColor = HEXCOLOR(0xAFA7EB).CGColor;
    self.btn_4.layer.borderWidth = 1.5;
}
- (void)loginButtonCreate{

    self.skilp = [[UIButton alloc] initWithFrame:(CGRect){__kwidth-80,310,60,60}];
    self.skilp.layer.masksToBounds = YES;
    self.skilp.layer.cornerRadius = 30;
    self.skilp.layer.borderWidth = 1.5;
    self.skilp.layer.borderColor = HEXCOLOR(0xAFA7EB).CGColor;
    [self.skilp setTitle:@"Login" forState:UIControlStateNormal];
    [self.skilp setTitleColor:HEXCOLOR(0xAFA7EB) forState:UIControlStateNormal];
    [self.skilp addTarget:self action:@selector(skilpAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.skilp];
    
    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(moveSkilpBtn:)];
    [self.skilp addGestureRecognizer:pan];
}
- (void)emitterAnimetion{
    CAEmitterLayer *emitter = [CAEmitterLayer layer];
    //发射模式
    emitter.emitterMode = kCAEmitterLayerSurface;
    //发射源的形状
    emitter.emitterShape = kCAEmitterLayerLine;
    //emitter.renderMode = kCAEmitterLayerAdditive;
    emitter.emitterPosition = CGPointMake(-100,260);
    
    CAEmitterCell *cell = [CAEmitterCell emitterCell];
    cell.contents = (__bridge id)[UIImage imageNamed:@"paopao"].CGImage;
    cell.birthRate = 2;
    cell.lifetime =10.0 ;
    cell.alphaSpeed = 0;
    cell.velocity = 80;
    cell.velocityRange = 100;
    cell.emissionLongitude = 2.35*M_PI;
    cell.emissionRange = M_PI /4 ;
    emitter.emitterCells = @[cell];
    [self.view.layer addSublayer:emitter];
}
//登陆页面跳转
- (void)moveSkilpBtn:(UIGestureRecognizer *)swipe{
    CGPoint point = [swipe locationInView:self.view];
    self.skilp.center = point;
}
//跳过
- (void)skilpAction{
    
    self.xl_pushTranstion = [XLBubbleTransition transitionWithAnchorRect:self.skilp.frame];
    self.xl_popTranstion = [XLBubbleTransition transitionWithAnchorRect:self.skilp.frame];
    
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"LoginViewController"];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
